import SDKManager from "../../sdk/SDKManager";
// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const { ccclass, property } = cc._decorator;

@ccclass
export default class CustomAdComp extends cc.Component {


    @property
    index: number = 0;

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start() {
        this.init();
    }

    init() {
        // if (PV.isBlockOpen(this.index)) {
        // if (SDKManager.getChannel().getMatrix().isSwtichOpen()) {
        let rx = this.node.x / this.node.parent.width;
        // console.log(' this.node.y ', this.node.y, ' this.node.parent.height ', this.node.parent.height)
        let ry = (this.node.parent.height - this.node.y) / this.node.parent.height;
        console.log(' rx == ry ====== ', rx, ry)
        SDKManager.getChannel().showCustomAd(this.index, rx, ry)
        // }
        // }
        setTimeout(() => {
            this.init();
        }, 30000);
    }

    // update (dt) {}
}
